#include "stdafx.h"
#include "Core.h"

#include "Graphics.h"
#include "ViewManager.h"

using namespace mcore;

Core::Core()
{
	mGraphics = new mgfx::Graphics;
	mViewMgr = new ViewManager;
}

Core::~Core()
{
	delete mViewMgr;
	delete mGraphics;
}

void Core::initGraphics(HWND hwnd, int clientWidth, int clientHeight)
{
	mGraphics->init(hwnd, clientWidth, clientHeight);
}

void Core::update(float dt)
{
	mViewMgr->update(dt);
	mGraphics->updateTimer(dt);
}

void Core::draw()
{
	mGraphics->preDraw();
	mViewMgr->draw();
	mGraphics->postDraw();
}

void Core::onResize()
{
	mViewMgr->onResize();
	//mGraphics->onResize();
}

bool Core::onWindowMessage(UINT msg, WPARAM wParam, LPARAM lParam)
{
	return mViewMgr->onWindowMessage(msg, wParam, lParam);
}